How to escalate an incident through the API

Hi there,

How do i reproduce the escalate button in the WebUI through the API? What are the different API calls needed given an incident id.

Regards

Hello,

Thanks for reaching out on our community page! The API call best suited for this would be ā€˜update incident’ - there are details on the document below. Specifically escalation_level and assign being the fields used to update the incident -

https://developer.pagerduty.com/api-reference/8a0e1aa2ec666-update-an-incident

Hope this helps.
John

John O’Donnell
Team Lead, EMEA Support@pagerduty.com

How do i know how to bump escalation_level to which integer ?

Hey Quentin,

The EP levels would correspond to the same number level they are in the UI. To get this information you will need to use the Get an incident to retrieve the Escalation Policy id from the escalation_policy object within the incident object (ensuring you note the assignee(s) in the assignments array to compare to the targets array in the next part). Then you will need to use Get an escalation policy using that id value to get the size of the escalation_rules array.

This requires some minor coding/scripting to find the size of the array as it isn’t a value that we return from an API call. The size of the array equals the number of escalation rules that are available. You can then drill down to the targets array to find the actual schedules or users that the Escalation Policy contains.

Comparing the targets to the assignees will allow you to understand which level of the escalation policy they are currently using, and then you can update the incident to escalate to whatever level by using Update an incident with a body like the below for example:

{
ā€œincidentā€: {
ā€œescalation_levelā€: 2,
ā€œtypeā€: ā€œincidentā€
}
}

Hope this helps.
John

John O’Donnell
Team Lead, EMEA Support@pagerduty.com

Thanks for this detailed answer.

Does Updating Incident assignments with new assignee without updating escalation_level is considered as an escalation for PD ?

Hello,

Updating the assignee field would be assigning it directly to a person, meaning there would be no automatic change if the user didn’t respond. But this would still work.

John

John O’Donnell
Team Lead, EMEA Support@pagerduty.com